// https://leetcode.cn/problems/maximum-number-of-balls-in-a-box/
// Created by ade on 2022/11/23.
//
#include<iostream>
#include<vector>

using namespace std;

class Solution {
public:
    int countBalls(int lowLimit, int highLimit) {
        unordered_map<int, int> m;
        int maxI = 0;
        for (int i = lowLimit; i <= highLimit; i++) {
            if (i < 10) {
                m[i]++;
                maxI = max(maxI, m[i]);
                continue;
            }
            int tmp = i, c = 0;
            while (tmp >= 10) {
                c += (tmp % 10);
                tmp = tmp / 10;
            }
            m[c]++;
            maxI = max(maxI, m[c]);
        }
        return maxI;
    }
};

int main() {
    Solution so;
    cout << so.countBalls(5, 15) << endl;
    return 0;
}